#include "TreeNode.h"
#include "CFGNode.h"

using namespace std;

// Constructors/destructor

TreeNode::TreeNode(void) {
	mTreeNodeType = AST_INVALID_TYPE;
	mParent = NULL;
	mContent = -1;
}

TreeNode::TreeNode(TreeNodeType treeNodeType) {
	mTreeNodeType = treeNodeType;
	mParent = NULL;
	mContent = -1;
}

TreeNode::TreeNode(TreeNodeType treeNodeType, int content) {
	mTreeNodeType = treeNodeType;
	mContent = content;
}

TreeNode::~TreeNode(void) {
}

// End of constructor/destructor section

void TreeNode::setNodeType(TreeNodeType treeNodeType) {
	mTreeNodeType = treeNodeType;
}

TreeNodeType TreeNode::getNodeType() {
	return mTreeNodeType;
}

void TreeNode::setContent(int content) {
	mContent = content;
}
		
int TreeNode::getContent() {
	return mContent;
}
		
void TreeNode::addChild(TreeNode* childNode) {
	mChildrenList.push_back(childNode);
}

void TreeNode::addChildFront(TreeNode* childNode) {
	mChildrenList.insert(mChildrenList.begin(),childNode);
}

void TreeNode::removeChildAtIndex(int index) {
	if (index < 0 || index >= (int)mChildrenList.size()) {
		// out of bounds
		return;
	}
	mChildrenList.erase( (mChildrenList.begin() + index) );
}

vector<TreeNode*> TreeNode::getChild() {
	return mChildrenList;
}
		
int TreeNode::getNumberOfChildren() {
	return mChildrenList.size();
}

void TreeNode::addParent(TreeNode* node){
	mParent = node;
}

TreeNode* TreeNode::getParent(){
	return mParent;
}

//bool TreeNode::setCFGNode(CFGNode* mcfgNode){
//	mCFGNode = mcfgNode;
//	return true;
//}
//
//CFGNode* TreeNode::getCFGNode(){
//	return mCFGNode;
//}